home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume15 / olvwm-3.0 / part19 < prev    next >
Encoding:
Internet Message Format  |  1992-02-03  |  55.9 KB

  1. Path: uunet!sun-barr!ames!pasteur!nntp
  2. From: scott.oaks@East.Sun.COM (Scott Oaks)
  3. Newsgroups: comp.sources.x
  4. Subject: v15i165: OpenLook Virtual Window Mgr (3.0), Part19/21
  5. Message-ID: <1992Feb4.140047.8312@pasteur.Berkeley.EDU>
  6. Date: 4 Feb 92 14:00:47 GMT
  7. References: <csx-15i147-olvwm-3.0@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: University of California, at Berkeley
  10. Lines: 2194
  11. Approved: dcmartin@msi.com
  12. Nntp-Posting-Host: postgres.berkeley.edu
  13.  
  14. Submitted-by: scott.oaks@East.Sun.COM (Scott Oaks)
  15. Posting-number: Volume 15, Issue 165
  16. Archive-name: olvwm-3.0/part19
  17.  
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  22. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  23. # If this archive is complete, you will see the following message at the end:
  24. #        "End of archive 19 (of 21)."
  25. # Contents:  atom.c cmdstream.c group.c resources.h st.c winmenu.c
  26. #   winnofoc.c winresize.c
  27. # Wrapped by dcmartin@fascet on Tue Jan 14 05:54:48 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'atom.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'atom.c'\"
  31. else
  32. echo shar: Extracting \"'atom.c'\" \(6058 characters\)
  33. sed "s/^X//" >'atom.c' <<'END_OF_FILE'
  34. X/*
  35. X *      (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
  36. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  37. X *      file for terms of the license.
  38. X */
  39. X
  40. X#ident    "@(#)atom.c    26.17    91/09/14 SMI"
  41. X
  42. X#include <X11/Xlib.h>
  43. X#include <X11/Xatom.h>
  44. X#include <X11/Xresource.h>
  45. X
  46. XAtom    AtomAtomPair;
  47. XAtom    AtomChangeState;
  48. XAtom    AtomClass;
  49. XAtom    AtomColorMapWindows;
  50. XAtom    AtomDecorAdd;
  51. XAtom    AtomDecorClose;
  52. XAtom    AtomDecorDel;
  53. XAtom    AtomDecorFooter;
  54. XAtom    AtomDecorHeader;
  55. XAtom    AtomDecorPin;
  56. XAtom    AtomDecorResize;
  57. XAtom    AtomDelete;
  58. XAtom    AtomDeleteWindow;
  59. XAtom    AtomDfltBtn;
  60. XAtom    AtomLeftFooter;
  61. XAtom    AtomLength;
  62. XAtom    AtomListLength;
  63. XAtom    AtomMenuFull;
  64. XAtom    AtomMenuLimited;
  65. XAtom    AtomMultiple;
  66. XAtom    AtomName;
  67. XAtom    AtomNone;
  68. XAtom    AtomOlwmTimestamp;
  69. XAtom    AtomPinIn;
  70. XAtom    AtomPinOut;
  71. XAtom    AtomProtocols;
  72. XAtom    AtomPushpinState;
  73. XAtom    AtomRightFooter;
  74. XAtom    AtomSaveYourself;
  75. XAtom    AtomShowProperties;
  76. XAtom    AtomSunViewEnv;
  77. XAtom    AtomTakeFocus;
  78. XAtom    AtomTargets;
  79. XAtom    AtomTimestamp;
  80. XAtom    AtomUser;
  81. XAtom    AtomWMClass;
  82. XAtom    AtomWMName;
  83. XAtom    AtomWMIconName;
  84. XAtom    AtomWMHints;
  85. XAtom    AtomWMNormalHints;
  86. XAtom    AtomWMSizeHints;
  87. XAtom    AtomWMTransientFor;
  88. XAtom    AtomWMApplyProperties;
  89. XAtom    AtomWMResetProperties;
  90. XAtom    AtomWMState;
  91. XAtom    AtomWTBase;
  92. XAtom    AtomWTCmd;
  93. XAtom    AtomWTHelp;
  94. XAtom    AtomWTNotice;
  95. XAtom    AtomWTOther;
  96. XAtom    AtomWinAttr;
  97. XAtom    AtomWindowBusy;
  98. XAtom    AtomSunLedMap;
  99. XAtom    AtomSunWMProtocols;
  100. XAtom    AtomSunWindowState;
  101. XAtom    AtomSunDragDropInterest;
  102. XAtom    AtomSunOLWinAttr5;
  103. XAtom    AtomDecorIconName;
  104. X
  105. X/***************************************************************************
  106. X* Global functions
  107. X***************************************************************************/
  108. X
  109. X/*
  110. X * InitAtoms -- initialize the atoms needed to communicate with Open
  111. X *    Look clients
  112. X */
  113. XInitAtoms(dpy)
  114. XDisplay    *dpy;
  115. X{
  116. X    /* ICCCM specific flags */
  117. X    AtomColorMapWindows = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
  118. X    AtomWMState = XInternAtom(dpy, "WM_STATE", False);
  119. X    AtomChangeState = XInternAtom(dpy, "WM_CHANGE_STATE" , False);
  120. X    AtomProtocols = XInternAtom(dpy, "WM_PROTOCOLS" , False);
  121. X    AtomTakeFocus = XInternAtom(dpy, "WM_TAKE_FOCUS" , False);
  122. X    AtomSaveYourself = XInternAtom(dpy, "WM_SAVE_YOURSELF" , False);
  123. X    AtomDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW" , False);
  124. X
  125. X    /* Predefined atoms - referenced from ClientDistributeProperties */
  126. X    AtomWMName = XA_WM_NAME;
  127. X    AtomWMIconName = XA_WM_ICON_NAME;
  128. X    AtomWMClass = XA_WM_CLASS;
  129. X    AtomWMHints = XA_WM_HINTS;
  130. X    AtomWMNormalHints = XA_WM_NORMAL_HINTS;
  131. X    AtomWMSizeHints = XA_WM_SIZE_HINTS;
  132. X    AtomWMTransientFor = XA_WM_TRANSIENT_FOR;
  133. X
  134. X    /* OpenLook specific flags */
  135. X    AtomWinAttr = XInternAtom(dpy, "_OL_WIN_ATTR" , False);
  136. X    AtomPushpinState = XInternAtom(dpy, "_OL_PIN_STATE" , False);
  137. X    AtomWindowBusy = XInternAtom(dpy, "_OL_WIN_BUSY" , False);
  138. X    AtomLeftFooter = XInternAtom(dpy, "_OL_WINMSG_ERROR" , False);
  139. X    AtomRightFooter = XInternAtom(dpy, "_OL_WINMSG_STATE" , False);
  140. X    AtomShowProperties = XInternAtom(dpy, "_OL_SHOW_PROPS" , False);
  141. X    AtomWMApplyProperties = XInternAtom(dpy, "_OL_PROPS_APPLY" , False);
  142. X    AtomWMResetProperties = XInternAtom(dpy, "_OL_PROPS_RESET" , False);
  143. X    AtomPinOut = XInternAtom(dpy, "_OL_PIN_OUT" , False);
  144. X    AtomDecorResize = XInternAtom(dpy, "_OL_DECOR_RESIZE" , False);
  145. X    AtomWTBase = XInternAtom(dpy, "_OL_WT_BASE" , False);
  146. X    AtomDecorFooter = XInternAtom(dpy, "_OL_DECOR_FOOTER" , False);
  147. X    AtomDecorAdd = XInternAtom(dpy, "_OL_DECOR_ADD" , False);
  148. X    AtomDecorDel = XInternAtom(dpy, "_OL_DECOR_DEL" , False);
  149. X    AtomDecorPin = XInternAtom(dpy, "_OL_DECOR_PIN" , False);
  150. X    AtomWTCmd = XInternAtom(dpy, "_OL_WT_CMD" , False);
  151. X    AtomPinIn = XInternAtom(dpy, "_OL_PIN_IN" , False);
  152. X    AtomNone = XInternAtom(dpy, "_OL_NONE" , False);
  153. X    AtomWTNotice = XInternAtom(dpy, "_OL_WT_NOTICE" , False);
  154. X    AtomMenuFull = XInternAtom(dpy, "_OL_MENU_FULL" , False);
  155. X    AtomDecorHeader = XInternAtom(dpy, "_OL_DECOR_HEADER" , False);
  156. X    AtomWTHelp = XInternAtom(dpy, "_OL_WT_HELP" , False);
  157. X    AtomMenuLimited = XInternAtom(dpy, "_OL_MENU_LIMITED" , False);
  158. X    AtomDecorClose = XInternAtom(dpy, "_OL_DECOR_CLOSE" , False);
  159. X    AtomWTOther = XInternAtom(dpy, "_OL_WT_OTHER" , False);
  160. X    AtomOlwmTimestamp = XInternAtom(dpy,"_OLWM_TIMESTAMP",False);
  161. X    AtomDfltBtn = XInternAtom(dpy, "_OL_DFLT_BTN", False);
  162. X    AtomDecorIconName = XInternAtom(dpy, "_OL_DECOR_ICON_NAME", False);
  163. X
  164. X    /* ICCCM selection atoms */
  165. X    AtomAtomPair = XInternAtom(dpy,"ATOM_PAIR",False);
  166. X    AtomClass = XInternAtom(dpy,"CLASS",False);
  167. X    AtomDelete = XInternAtom(dpy,"DELETE",False);
  168. X    AtomMultiple = XInternAtom(dpy,"MULTIPLE",False);
  169. X    AtomLength = XInternAtom(dpy,"LENGTH",False);
  170. X    AtomListLength = XInternAtom(dpy,"LIST_LENGTH",False);
  171. X    AtomName = XInternAtom(dpy,"NAME",False);
  172. X    AtomTargets = XInternAtom(dpy,"TARGETS",False);
  173. X    AtomTimestamp = XInternAtom(dpy,"TIMESTAMP",False);
  174. X    AtomUser = XInternAtom(dpy,"USER",False);
  175. X
  176. X    /* SunView environment */
  177. X    AtomSunViewEnv = XInternAtom(dpy,"_SUN_SUNVIEW_ENV",False);
  178. X
  179. X    /* Sun window manager atoms */
  180. X    AtomSunLedMap = XInternAtom(dpy,"_SUN_LED_MAP",False);
  181. X    AtomSunWMProtocols = XInternAtom(dpy,"_SUN_WM_PROTOCOLS",False);
  182. X    AtomSunWindowState = XInternAtom(dpy,"_SUN_WINDOW_STATE",False);
  183. X    AtomSunOLWinAttr5 = XInternAtom(dpy,"_SUN_OL_WIN_ATTR_5",False);
  184. X
  185. X    AtomSunDragDropInterest =
  186. X        XInternAtom(dpy, "_SUN_DRAGDROP_INTEREST", False);
  187. X}
  188. X
  189. X#ifdef notdef
  190. X/* XXX remove after properties.c working */
  191. Xvoid *
  192. XGetWindowProperty(dpy, w, property, long_offset, long_length, req_type, 
  193. X    req_fmt, nitems, bytes_after)
  194. XDisplay *dpy;
  195. XWindow w;
  196. XAtom property;
  197. Xlong long_offset, long_length;
  198. XAtom req_type;
  199. Xint req_fmt;
  200. Xunsigned long *nitems;
  201. Xunsigned long *bytes_after;
  202. X{
  203. X    int status;
  204. X    unsigned char *prop;
  205. X    Atom act_type;
  206. X    int act_format;
  207. X
  208. X    status = XGetWindowProperty(dpy, w, property, long_offset, long_length,
  209. X            False, req_type, &act_type, &act_format, nitems,
  210. X            bytes_after, &prop);
  211. X    if ((status != Success) || (act_type != req_type))
  212. X    {
  213. X        *nitems = 0;
  214. X        return NULL;
  215. X    }
  216. X    if ((req_fmt != 0) && (act_format != req_fmt))
  217. X    {
  218. X        XFree((char *)prop);
  219. X        *nitems = 0;
  220. X        return NULL;
  221. X    }
  222. X    return (void *)prop;
  223. X}
  224. X#endif
  225. END_OF_FILE
  226. if test 6058 -ne `wc -c <'atom.c'`; then
  227.     echo shar: \"'atom.c'\" unpacked with wrong size!
  228. fi
  229. # end of 'atom.c'
  230. fi
  231. if test -f 'cmdstream.c' -a "${1}" != "-c" ; then 
  232.   echo shar: Will not clobber existing file \"'cmdstream.c'\"
  233. else
  234. echo shar: Extracting \"'cmdstream.c'\" \(6016 characters\)
  235. sed "s/^X//" >'cmdstream.c' <<'END_OF_FILE'
  236. X/*
  237. X *      (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
  238. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  239. X *      file for terms of the license.
  240. X */
  241. X/* ----------------------------------------------------------------------
  242. X *      cmdstream.c
  243. X * ---------------------------------------------------------------------*/
  244. X
  245. X#ident    "@(#)cmdstream.c    26.6    91/09/14 SMI"
  246. X
  247. X#include <stdio.h>
  248. X#ifdef SYSV
  249. X#include <string.h>
  250. X#else
  251. X#include <strings.h>
  252. X#endif
  253. X#include "cmdstream.h"
  254. X#include "mem.h"
  255. X
  256. Xextern    char    *strtok();
  257. X
  258. X/* ----------------------------------------------------------------------
  259. X *      Local Data Structures
  260. X * ---------------------------------------------------------------------*/
  261. X
  262. Xtypedef struct _CList {
  263. X    Command        *this;
  264. X    struct _CList    *next;
  265. X} CList;
  266. X
  267. Xtypedef struct _CmdInfo {
  268. X    FILE        *input;
  269. X    FILE        *output;
  270. X    CList        *cmdListHead;
  271. X} CmdInfo;
  272. X
  273. X/* ----------------------------------------------------------------------
  274. X *      Data Definitions
  275. X * ---------------------------------------------------------------------*/
  276. X
  277. Xstatic    CmdInfo        cmdInfo = {
  278. X    (FILE *)0, (FILE *)0, (CList *)0
  279. X};
  280. X
  281. X/* ----------------------------------------------------------------------
  282. X *      Local Forward Declarations
  283. X * ---------------------------------------------------------------------*/
  284. X
  285. XCommand        *MatchCommand();
  286. XCmdAttr        *MatchAttr();
  287. Xint        EncodeAttrValue();
  288. Xint        DecodeAttrValue();
  289. X
  290. X/* ----------------------------------------------------------------------
  291. X *      SetCmdStream
  292. X * ---------------------------------------------------------------------*/
  293. Xvoid
  294. XSetCmdStream(instream,outstream)
  295. X    FILE        *instream;
  296. X    FILE        *outstream;
  297. X{
  298. X    cmdInfo.input = instream;
  299. X    cmdInfo.output = outstream;
  300. X}
  301. X
  302. X/* ----------------------------------------------------------------------
  303. X *      SendCmd
  304. X * ---------------------------------------------------------------------*/
  305. Xint
  306. XSendCmd(cmd)
  307. X    Command        *cmd;
  308. X{
  309. X    CmdAttr        *attr;
  310. X    int        i;
  311. X
  312. X    if (cmdInfo.output == (FILE *)NULL)
  313. X        return FALSE;
  314. X
  315. X    fprintf(cmdInfo.output,"%s\n",cmd->keyword);
  316. X    for (i=0; i<cmd->attrLen; i++) {
  317. X        attr = &(cmd->attrList[i]);
  318. X        fprintf(cmdInfo.output,"\t%s=",attr->name);
  319. X        EncodeAttrValue(attr,cmdInfo.output);
  320. X        fputs("\n",cmdInfo.output);
  321. X    }
  322. X    fputs(";\n",cmdInfo.output);
  323. X    fflush(cmdInfo.output);
  324. X    return TRUE;
  325. X}
  326. X
  327. X/* ----------------------------------------------------------------------
  328. X *      RegisterCmd
  329. X * ---------------------------------------------------------------------*/
  330. Xvoid
  331. XRegisterCmd(cmd)
  332. X    Command        *cmd;
  333. X{
  334. X    CList        *item;
  335. X
  336. X    item = MemNew(CList);
  337. X    item->this = cmd;
  338. X    item->next = cmdInfo.cmdListHead;
  339. X    cmdInfo.cmdListHead = item;
  340. X}
  341. X
  342. X/* ----------------------------------------------------------------------
  343. X *      GetCmd
  344. X * ---------------------------------------------------------------------*/
  345. Xint
  346. XGetCmd()
  347. X{
  348. X#define    CMDBUFLEN    1024
  349. X    char        cmdBuf[CMDBUFLEN];
  350. X
  351. X    while (fgets(cmdBuf,CMDBUFLEN,cmdInfo.input) != (char *)NULL) {
  352. X        if (ParseCmd(cmdBuf) == FALSE)
  353. X            return FALSE;
  354. X    }
  355. X    return TRUE;
  356. X}
  357. X
  358. X/* ----------------------------------------------------------------------
  359. X *      ParseCmd
  360. X * ---------------------------------------------------------------------*/
  361. Xint
  362. XParseCmd(line)
  363. X    char        *line;
  364. X{
  365. X    char        *token;
  366. X    char        *sep = " \t\n";
  367. X    static Command    *cmd = (Command *)NULL;
  368. X    static CmdAttr    *attr = (CmdAttr *)NULL;
  369. X
  370. X    for (token=strtok(line,sep); token; token=strtok(0,sep)) { 
  371. X        if (cmd == (Command *)NULL) {
  372. X            if ((cmd = MatchCommand(token)) == (Command *)NULL)
  373. X                return FALSE;
  374. X        } else if (token[0] == ';') {
  375. X            if (cmd->callback)
  376. X                (*cmd->callback)(cmd);
  377. X            cmd = (Command *)NULL;
  378. X            attr = (CmdAttr *)NULL;
  379. X        } else {
  380. X            if ((attr = MatchAttr(cmd,token)) == (CmdAttr *)NULL) {
  381. X                cmd = (Command *)NULL;
  382. X                return FALSE;
  383. X            }
  384. X        }
  385. X    }
  386. X    return FALSE;
  387. X}
  388. X
  389. X/* ----------------------------------------------------------------------
  390. X *      MatchKeyword
  391. X * ---------------------------------------------------------------------*/
  392. Xstatic Command *
  393. XMatchCommand(keyword)
  394. X    char        *keyword;
  395. X{
  396. X    CList        *item;
  397. X
  398. X    for (item=cmdInfo.cmdListHead; item; item=item->next) {
  399. X        if (!strcmp(keyword,item->this->keyword)) {
  400. X            return item->this;
  401. X        }
  402. X    }
  403. X    return (Command *)NULL;
  404. X}
  405. X
  406. X/* ----------------------------------------------------------------------
  407. X *      MatchAttr
  408. X * ---------------------------------------------------------------------*/
  409. Xstatic CmdAttr *
  410. XMatchAttr(cmd,name)
  411. X    Command        *cmd;
  412. X    char        *name;
  413. X{
  414. X    int        i,equalindex;
  415. X    char        *equalpos;
  416. X    char        *strchr();
  417. X
  418. X    equalpos = strchr(name,'=');
  419. X
  420. X    if (!equalpos)
  421. X        return (CmdAttr *)NULL;
  422. X
  423. X    equalindex = equalpos - name;
  424. X
  425. X    for (i=0; i<cmd->attrLen; i++) {
  426. X        if (!strncmp(name,cmd->attrList[i].name,equalindex)) {
  427. X            if (!DecodeAttrValue(&cmd->attrList[i],++equalpos))
  428. X                return (CmdAttr *)NULL;
  429. X            return &(cmd->attrList[i]);
  430. X        }
  431. X    }
  432. X    return (CmdAttr *)NULL;
  433. X}
  434. X
  435. X/* ----------------------------------------------------------------------
  436. X *      EncodeAttrValue
  437. X * ---------------------------------------------------------------------*/
  438. Xstatic int
  439. XEncodeAttrValue(attr,stream)
  440. X    CmdAttr        *attr;
  441. X    FILE        *stream;
  442. X{
  443. X    switch (attr->type) {
  444. X    case INT:    fprintf(stream,"%d",attr->value.ival);
  445. X            break;
  446. X    case FLOAT:    fprintf(stream,"%f",attr->value.fval);
  447. X            break;
  448. X    case STRING:    fprintf(stream,"%s",attr->value.sval);
  449. X            break;
  450. X    }
  451. X    return TRUE;
  452. X}
  453. X
  454. X/* ----------------------------------------------------------------------
  455. X *      DecodeAttrValue
  456. X * ---------------------------------------------------------------------*/
  457. Xstatic int
  458. XDecodeAttrValue(attr,valuestr)
  459. X    CmdAttr        *attr;
  460. X    char        *valuestr;
  461. X{
  462. X    char        *ptr;
  463. X    int        status = TRUE;
  464. X
  465. X    switch (attr->type) {
  466. X    case INT:    attr->value.ival = (int)strtol(valuestr,&ptr,10);
  467. X            if (ptr == valuestr)
  468. X                status = FALSE;
  469. X            break;
  470. X    case FLOAT:     attr->value.fval = (float)strtod(valuestr,&ptr);
  471. X            if (ptr == valuestr)
  472. X                status = FALSE;
  473. X            break;
  474. X    case STRING:    attr->value.sval = MemNewString(valuestr);
  475. X            if (attr->value.sval == (char *)NULL)
  476. X                status = FALSE;
  477. X            break;
  478. X    default:
  479. X            status = FALSE;
  480. X            break;
  481. X    }
  482. X    return status;
  483. X}
  484. END_OF_FILE
  485. if test 6016 -ne `wc -c <'cmdstream.c'`; then
  486.     echo shar: \"'cmdstream.c'\" unpacked with wrong size!
  487. fi
  488. # end of 'cmdstream.c'
  489. fi
  490. if test -f 'group.c' -a "${1}" != "-c" ; then 
  491.   echo shar: Will not clobber existing file \"'group.c'\"
  492. else
  493. echo shar: Extracting \"'group.c'\" \(6503 characters\)
  494. sed "s/^X//" >'group.c' <<'END_OF_FILE'
  495. X/*
  496. X *      (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
  497. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  498. X *      file for terms of the license.
  499. X */
  500. X
  501. X#ident    "@(#)group.c    26.7    91/09/14 SMI"
  502. X
  503. X#include <stdio.h>
  504. X#include <X11/Xos.h>
  505. X#include <X11/Xlib.h>
  506. X#include <X11/Xutil.h>
  507. X#include "i18n.h"
  508. X#include "mem.h"
  509. X#include "st.h"
  510. X#include "olwm.h"
  511. X#include "win.h"
  512. X#include "list.h"
  513. X#include "group.h"
  514. X
  515. X/***************************************************************************
  516. X* Local data
  517. X***************************************************************************/
  518. X
  519. Xstatic st_table *groupHashTable;
  520. X
  521. X/***************************************************************************
  522. X* Local functions
  523. X***************************************************************************/
  524. X
  525. X/* groupFindList -- find a client in a list of clients; return a given
  526. X * value if found or 0 otherwise.  If passed a pointer to a List **, set that.
  527. X */
  528. Xstatic unsigned int
  529. XgroupFindList(plist, cli, retlist, retval)
  530. XList **plist;
  531. XClient *cli;
  532. XList ***retlist;
  533. Xunsigned int retval;
  534. X{
  535. X    if ((cli == NULL) || (*plist == NULL))
  536. X    {
  537. X        if (retlist != NULL)
  538. X            *retlist = NULL;
  539. X        return 0;
  540. X    }
  541. X
  542. X    if ((*plist)->value == cli)
  543. X    {
  544. X        if (retlist != NULL)
  545. X            *retlist = plist;
  546. X        return retval;
  547. X    }
  548. X    return groupFindList(&((*plist)->next), cli, retlist, retval);
  549. X}
  550. X
  551. X
  552. X/* groupFindCli -- find a client in a group.  Return a mask indicating
  553. X * which category of client the client was found in, if any; if a list
  554. X * pointer is passed in, return a pointer to a List * in that parameters
  555. X * (presumably for list deletion).
  556. X */
  557. Xstatic unsigned int
  558. XgroupFindCli(group, cli, ppList)
  559. XGroup *group;
  560. XClient *cli;
  561. XList ***ppList;
  562. X{
  563. X    unsigned int retmask;
  564. X
  565. X    if (cli == group->leader)
  566. X    {
  567. X        retmask = GROUP_LEADER;
  568. X    }
  569. X    else
  570. X    {
  571. X    if ((retmask = groupFindList(&(group->dependents), cli, ppList, 
  572. X      GROUP_DEPENDENT)) == 0)
  573. X        retmask = groupFindList(&(group->independents), cli, ppList, 
  574. X        GROUP_INDEPENDENT);
  575. X    }
  576. X    return retmask;
  577. X}
  578. X
  579. X/* groupCompare -- utility function to compare two group id's
  580. X */
  581. Xstatic int
  582. XgroupCompare(g1,g2)
  583. Xregister char *g1, *g2;
  584. X{
  585. X    return ((GroupID)g1) - ((GroupID)g2);
  586. X}
  587. X
  588. X/* groupHash -- hash function for group id lookup table 
  589. X */
  590. Xstatic int
  591. XgroupHash(g1, modulus)
  592. Xregister char *g1;
  593. Xregister int modulus;
  594. X{
  595. X    return ((GroupID)g1)%modulus;
  596. X}
  597. X
  598. X/* groupInsert -- put a group structure into the lookup table
  599. X */
  600. Xstatic void
  601. XgroupInsert(group)
  602. XGroup *group;
  603. X{
  604. X    st_insert(groupHashTable, (int)group->groupid, (char *)group);
  605. X}
  606. X
  607. X/* groupDelete -- remove a group structure from the lookup table
  608. X */
  609. Xstatic Bool
  610. XgroupDelete(grpid)
  611. XGroupID grpid;
  612. X{
  613. X    Group *oldGrp;
  614. X    GroupID tmpGrp = grpid;
  615. X    GroupID *tmpGrpPtr = &tmpGrp;
  616. X
  617. X    return st_delete(groupHashTable, (char *)tmpGrpPtr, (char *)&oldGrp);
  618. X}
  619. X
  620. X/***************************************************************************
  621. X* Global functions
  622. X***************************************************************************/
  623. X
  624. X/*
  625. X * GroupInit -- initialises the hash table used to map group id's to
  626. X *     group structures.
  627. X */
  628. Xvoid 
  629. XGroupInit()
  630. X{
  631. X    groupHashTable = st_init_table(groupCompare, groupHash);
  632. X}
  633. X
  634. X
  635. X/* GroupApply -- applies a function to each part of the group identified 
  636. X * in the mask; as with any apply function, when the function returns
  637. X * a non-NULL value application stops and that value is returned.
  638. X */
  639. Xvoid *
  640. XGroupApply(grpid, func, closure, mask)
  641. XGroupID grpid;
  642. XGroupFunc func;
  643. Xvoid *closure;
  644. Xunsigned int mask;
  645. X{
  646. X    Group *group;
  647. X    void *res = NULL;
  648. X
  649. X    group = GroupLookup(grpid);
  650. X    if (group == NULL)
  651. X        return NULL;
  652. X
  653. X    if ((mask & GROUP_LEADER) && (group->leader != NULL))
  654. X    {
  655. X        res = (func)(group->leader, closure);
  656. X    }
  657. X
  658. X    if ((mask & GROUP_DEPENDENT) && (group->dependents != NULL) && 
  659. X        (res == NULL))
  660. X    {
  661. X        res = ListApply(group->dependents,func,closure);
  662. X    }
  663. X
  664. X    if ((mask & GROUP_INDEPENDENT) && (group->independents != NULL) && 
  665. X        (res == NULL))
  666. X    {
  667. X        res = ListApply(group->independents,func,closure);
  668. X    }
  669. X
  670. X    return res;
  671. X}
  672. X
  673. X/* GroupLookup -- given a GroupID, returns the associated group structure, 
  674. X * or NULL if there is none.
  675. X */
  676. XGroup *
  677. XGroupLookup(group)
  678. XGroupID group;
  679. X{
  680. X    Group *tmp = NULL;
  681. X
  682. X    st_lookup(groupHashTable, group, &tmp);
  683. X    return tmp;
  684. X}
  685. X
  686. X/* GroupAdd -- adds a client to the named group, creating the group if need be.
  687. X * The kind of client is specified in the mask field.  Returns True
  688. X * if the client was successfully added.
  689. X */
  690. XBool 
  691. XGroupAdd(grpid, cli, mask)
  692. XGroupID grpid;
  693. XClient *cli;
  694. Xunsigned int mask;
  695. X{
  696. X    Group *group;
  697. X    unsigned int currmask;
  698. X
  699. X    group = GroupLookup(grpid);
  700. X    if (group == NULL)
  701. X    {
  702. X        group = MemNew(Group);
  703. X        group->groupid = grpid;
  704. X        groupInsert(group);
  705. X        currmask = 0;
  706. X    }
  707. X    else
  708. X    {
  709. X        currmask = groupFindCli(group, cli, NULL);
  710. X    }
  711. X    
  712. X    if (mask & GROUP_LEADER)
  713. X    {
  714. X        if ((currmask == 0) || (group->leader == cli))
  715. X        {
  716. X            group->leader = cli;
  717. X            return True;
  718. X        }
  719. X        else
  720. X            return False;
  721. X    }
  722. X    else if (mask & GROUP_DEPENDENT)
  723. X    {
  724. X        if (currmask != 0)
  725. X            return False;
  726. X        group->dependents = ListCons(cli,group->dependents);
  727. X    }
  728. X    else if (mask & GROUP_INDEPENDENT)
  729. X    {
  730. X        if (currmask != 0)
  731. X            return False;
  732. X        group->independents = ListCons(cli,group->independents);
  733. X    }
  734. X    return True;
  735. X}
  736. X
  737. X/* GroupRemove -- removes a client from the group.  If the group becomes empty
  738. X * it is deleted.  Returns True if the client was successfully deleted.
  739. X */
  740. XBool 
  741. XGroupRemove(grpid,cli)
  742. XGroupID grpid;
  743. XClient *cli;
  744. X{
  745. X    Group *group;
  746. X    unsigned int mask;
  747. X    List **plist;
  748. X
  749. X    group = GroupLookup(grpid);
  750. X    if (group == NULL)
  751. X        return False;
  752. X
  753. X    mask = groupFindCli(group, cli, &plist);
  754. X    if (mask == GROUP_LEADER)
  755. X    {
  756. X        group->leader = NULL;
  757. X    }
  758. X    else if ((mask == GROUP_DEPENDENT) || (mask == GROUP_INDEPENDENT))
  759. X    {
  760. X        ListDestroyCell(plist);
  761. X    }
  762. X    else
  763. X    {
  764. X        return False;
  765. X    }
  766. X    if ((group->leader == NULL) && (group->dependents == NULL) && 
  767. X        (group->independents == NULL))
  768. X    {
  769. X        groupDelete(group->groupid);
  770. X        MemFree(group);
  771. X    }
  772. X    return True;
  773. X}
  774. X
  775. X
  776. X/* GroupIsLeader -- returns whether a particular client is leader of a group
  777. X *    If the group hasn't been registered yet, assume that this client is 
  778. X *    its leader.
  779. X */
  780. XBool
  781. XGroupIsLeader(grpid, cli)
  782. XGroupID grpid;
  783. XClient *cli;
  784. X{
  785. X    Group *group;
  786. X
  787. X    group = GroupLookup(grpid);
  788. X    if (group == NULL)
  789. X        return True;
  790. X    return (group->leader == cli);
  791. X}
  792. X
  793. X
  794. X/* GroupLeader -- returns the leader of a group
  795. X */
  796. XClient *
  797. XGroupLeader(grpid)
  798. XGroupID grpid;
  799. X{
  800. X    Group *group;
  801. X
  802. X    group = GroupLookup(grpid);
  803. X    if (group == NULL)
  804. X        return NULL;
  805. X    else
  806. X        return group->leader;
  807. X}
  808. END_OF_FILE
  809. if test 6503 -ne `wc -c <'group.c'`; then
  810.     echo shar: \"'group.c'\" unpacked with wrong size!
  811. fi
  812. # end of 'group.c'
  813. fi
  814. if test -f 'resources.h' -a "${1}" != "-c" ; then 
  815.   echo shar: Will not clobber existing file \"'resources.h'\"
  816. else
  817. echo shar: Extracting \"'resources.h'\" \(1013 characters\)
  818. sed "s/^X//" >'resources.h' <<'END_OF_FILE'
  819. X/*
  820. X *      (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
  821. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  822. X *      file for terms of the license.
  823. X */
  824. X
  825. X#ident  "@(#)resources.h    1.1 olvwm version 1/3/92"
  826. X
  827. X/*
  828. X * Based on
  829. X#ident    "@(#)resources.h    26.16    91/09/14 SMI"
  830. X *
  831. X */
  832. X
  833. X#ifndef _OLWM_RESOURCES_H
  834. X#define _OLWM_RESOURCES_H
  835. X
  836. X#include <X11/Xresource.h>
  837. X
  838. X/* maximum length of fully-specified instance/class name */
  839. X#define    MAX_NAME    100
  840. X#define    MAX_CLASS    100
  841. X
  842. X#define BASICPTR    0
  843. X#define MOVEPTR        1
  844. X#define BUSYPTR        2
  845. X#define ICONPTR        3
  846. X#define RESIZEPTR    4
  847. X#define MENUPTR        5
  848. X#define QUESTIONPTR    6
  849. X#define TARGETPTR    7
  850. X#define PANPTR        8
  851. X#define NUM_CURSORS    9        /* number of pointers supported */
  852. X
  853. Xextern XrmQuark TopClassQ;
  854. Xextern XrmQuark TopInstanceQ;
  855. Xextern XrmQuark OpenWinQ;
  856. Xextern XrmQuark OlwmQ;
  857. Xextern XrmDatabase OlwmDB;
  858. X
  859. Xextern void InitGlobals();
  860. Xextern void UpdateGlobals();
  861. X
  862. X#ifdef OW_I18N_L3
  863. Xextern void EffectOLLC();
  864. X#endif /* OW_I18N_L3 */
  865. X
  866. X#endif /* _OLWM_RESOURCES_H */
  867. END_OF_FILE
  868. if test 1013 -ne `wc -c <'resources.h'`; then
  869.     echo shar: \"'resources.h'\" unpacked with wrong size!
  870. fi
  871. # end of 'resources.h'
  872. fi
  873. if test -f 'st.c' -a "${1}" != "-c" ; then 
  874.   echo shar: Will not clobber existing file \"'st.c'\"
  875. else
  876. echo shar: Extracting \"'st.c'\" \(8091 characters\)
  877. sed "s/^X//" >'st.c' <<'END_OF_FILE'
  878. X/* This is a general purpose hash table package written by Peter Moore @ UCB. */
  879. X#ident    "@(#)st.c    26.6    91/09/14 SMI"
  880. X
  881. X#include <stdio.h>
  882. X#include "st.h"
  883. X#include "mem.h"
  884. X
  885. X
  886. X#define max(a,b) ((a) > (b) ? (a) : (b))
  887. X#define nil(type) ((type *) 0)
  888. X#define alloc(type) (type *)MemAlloc((unsigned)sizeof(type))
  889. X#define Calloc(n,s) (char *)MemCalloc((n),(s))
  890. X
  891. X    /*
  892. X     * DEFAULT_MAX_DENSITY is the default for the largest we allow the
  893. X     * average number of items per bin before increasing the number of
  894. X     * bins
  895. X     *
  896. X     * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
  897. X     * allocated initially
  898. X     *
  899. X     * DEFAULT_GROW_FACTOR is the amount the hash table is expanded after
  900. X     * the density has reached max_density
  901. X     */
  902. X
  903. X#define EQUAL(func, x, y) \
  904. X    ((func == ST_NUMCMP) ? ((x) == (y)) : ((*func)((x), (y)) == 0))
  905. X
  906. X/*#define do_hash(key, table) (*table->hash)(key, table->num_bins)*/
  907. X
  908. X#define do_hash(key, table)\
  909. X    ((table->hash == ST_PTRHASH) ? (((int) (key) >> 2) % table->num_bins) :\
  910. X    (table->hash == ST_NUMHASH) ? ((int) (key) % table->num_bins) :\
  911. X    (*table->hash)((key), table->num_bins))
  912. X
  913. Xst_table *st_init_table_with_params(compare, hash, size, density, grow_factor,
  914. X                    reorder_flag)
  915. Xint (*compare)();
  916. Xint (*hash)();
  917. Xint size;
  918. Xint density;
  919. Xdouble grow_factor;
  920. Xint reorder_flag;
  921. X{
  922. X    st_table *new;
  923. X
  924. X    new = alloc(st_table);
  925. X    new->compare = compare;
  926. X    new->hash = hash;
  927. X    new->num_entries = 0;
  928. X    new->max_density = density;
  929. X    new->grow_factor = grow_factor;
  930. X    new->reorder_flag = reorder_flag;
  931. X    new->num_bins = size;
  932. X    new->bins = 
  933. X    (st_table_entry **) Calloc((unsigned)size, sizeof(st_table_entry *));
  934. X    return new;
  935. X}
  936. X
  937. Xst_table *st_init_table(compare, hash)
  938. Xint (*compare)();
  939. Xint (*hash)();
  940. X{
  941. X    return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
  942. X                     ST_DEFAULT_MAX_DENSITY,
  943. X                     ST_DEFAULT_GROW_FACTOR,
  944. X                     ST_DEFAULT_REORDER_FLAG);
  945. X}
  946. X                
  947. Xst_free_table(table)
  948. Xst_table *table;
  949. X{
  950. X    register st_table_entry *ptr, *next;
  951. X    int i;
  952. X
  953. X    for(i = 0; i < table->num_bins ; i++) {
  954. X    ptr = table->bins[i];
  955. X    while (ptr != nil(st_table_entry)) {
  956. X        next = ptr->next;
  957. X        free((char *) ptr);
  958. X        ptr = next;
  959. X    }
  960. X    }
  961. X    free((char *) table->bins);
  962. X    free((char *) table);
  963. X}
  964. X
  965. X#define PTR_NOT_EQUAL(table, ptr, key)\
  966. X(ptr != nil(st_table_entry) && !EQUAL(table->compare, key, (ptr)->key))
  967. X
  968. X#define FIND_ENTRY(table, ptr, hashval)\
  969. Xptr = (table)->bins[hashval];\
  970. Xif (PTR_NOT_EQUAL(table, ptr, key)) {\
  971. X    while (PTR_NOT_EQUAL(table, ptr->next, key)) {\
  972. X    ptr = ptr->next;\
  973. X    }\
  974. X    if (ptr->next != nil(st_table_entry) && (table)->reorder_flag) {\
  975. X    st_table_entry *_tmp = (ptr)->next;\
  976. X    (ptr)->next = (ptr)->next->next;\
  977. X    _tmp->next = (table)->bins[hashval];\
  978. X    (table)->bins[hashval] = _tmp;\
  979. X    ptr = _tmp;\
  980. X    } else {\
  981. X    ptr = ptr->next;\
  982. X    }\
  983. X}
  984. X    
  985. Xst_lookup(table, key, value)
  986. Xst_table *table;
  987. Xregister char *key;
  988. Xchar **value;
  989. X{
  990. X    int hash_val;
  991. X    register st_table_entry *ptr;
  992. X
  993. X    hash_val = do_hash(key, table);
  994. X
  995. X    FIND_ENTRY(table, ptr, hash_val);
  996. X    
  997. X    if (ptr == nil(st_table_entry)) {
  998. X    return 0;
  999. X    } else {
  1000. X    if (value != nil(char *))  *value = ptr->record; 
  1001. X    return 1;
  1002. X    }
  1003. X}
  1004. X
  1005. X#define ADD_DIRECT(table, key, value, hash_val, new)\
  1006. X{\
  1007. X    if (table->num_entries/table->num_bins > table->max_density) {\
  1008. X    rehash(table);\
  1009. X    hash_val = do_hash(key,table);\
  1010. X    }\
  1011. X    \
  1012. X    new = alloc(st_table_entry);\
  1013. X    \
  1014. X    new->key = key;\
  1015. X    new->record = value;\
  1016. X    new->next = table->bins[hash_val];\
  1017. X    table->bins[hash_val] = new;\
  1018. X    table->num_entries++;\
  1019. X}
  1020. X
  1021. Xst_insert(table, key, value)
  1022. Xregister st_table *table;
  1023. Xregister char *key;
  1024. Xchar *value;
  1025. X{
  1026. X    int hash_val;
  1027. X    st_table_entry *new;
  1028. X    register st_table_entry *ptr;
  1029. X
  1030. X    hash_val = do_hash(key, table);
  1031. X
  1032. X    FIND_ENTRY(table, ptr, hash_val);
  1033. X
  1034. X    if (ptr == nil(st_table_entry)) {
  1035. X    ADD_DIRECT(table,key,value,hash_val,new);
  1036. X    return 0;
  1037. X    } else {
  1038. X    ptr->record = value;
  1039. X    return 1;
  1040. X    }
  1041. X}
  1042. X
  1043. Xst_add_direct(table, key, value)
  1044. Xst_table *table;
  1045. Xchar *key;
  1046. Xchar *value;
  1047. X{
  1048. X    int hash_val;
  1049. X    st_table_entry *new;
  1050. X    
  1051. X    hash_val = do_hash(key, table);
  1052. X    ADD_DIRECT(table, key, value, hash_val, new);
  1053. X}
  1054. X
  1055. Xst_find_or_add(table, key, slot)
  1056. Xst_table *table;
  1057. Xchar *key;
  1058. Xchar ***slot;
  1059. X{
  1060. X    int hash_val;
  1061. X    st_table_entry *new, *ptr;
  1062. X
  1063. X    hash_val = do_hash(key, table);
  1064. X
  1065. X    FIND_ENTRY(table, ptr, hash_val);
  1066. X
  1067. X    if (ptr == nil(st_table_entry)) {
  1068. X    ADD_DIRECT(table, key, (char *)0, hash_val, new)
  1069. X    if (slot != nil(char **)) *slot = &new->record;
  1070. X    return 0;
  1071. X    } else {
  1072. X    if (slot != nil(char **)) *slot = &ptr->record;
  1073. X    return 1;
  1074. X    }
  1075. X}
  1076. X
  1077. Xstatic rehash(table)
  1078. Xregister st_table *table;
  1079. X{
  1080. X    register st_table_entry *ptr, *next, **old_bins = table->bins;
  1081. X    int i, old_num_bins = table->num_bins, hash_val;
  1082. X
  1083. X    table->num_bins = table->grow_factor*old_num_bins;
  1084. X    
  1085. X    if (table->num_bins%2 == 0) {
  1086. X    table->num_bins += 1;
  1087. X    }
  1088. X    
  1089. X    table->num_entries = 0;
  1090. X    table->bins = 
  1091. X      (st_table_entry **) Calloc((unsigned) table->num_bins,
  1092. X        sizeof(st_table_entry *));
  1093. X
  1094. X    for(i = 0; i < old_num_bins ; i++) {
  1095. X    ptr = old_bins[i];
  1096. X    while (ptr != nil(st_table_entry)) {
  1097. X        next = ptr->next;
  1098. X        hash_val = do_hash(ptr->key, table);
  1099. X        ptr->next = table->bins[hash_val];
  1100. X        table->bins[hash_val] = ptr;
  1101. X        table->num_entries++;
  1102. X        ptr = next;
  1103. X    }
  1104. X    }
  1105. X    free((char *) old_bins);
  1106. X}
  1107. X
  1108. Xst_table *st_copy(old_table)
  1109. Xst_table *old_table;
  1110. X{
  1111. X    st_table *new_table;
  1112. X    st_table_entry *ptr, *new;
  1113. X    int i, num_bins = old_table->num_bins;
  1114. X
  1115. X    new_table = alloc(st_table);
  1116. X    if (new_table == nil(st_table)) {
  1117. X    return nil(st_table);
  1118. X    }
  1119. X    
  1120. X    *new_table = *old_table;
  1121. X    new_table->bins = 
  1122. X      (st_table_entry **) Calloc((unsigned) num_bins, sizeof(st_table_entry *));
  1123. X    
  1124. X    if (new_table->bins == nil(st_table_entry *)) {
  1125. X    free((char *) new_table);
  1126. X    return nil(st_table);
  1127. X    }
  1128. X
  1129. X    for(i = 0; i < num_bins ; i++) {
  1130. X    new_table->bins[i] = nil(st_table_entry);
  1131. X    ptr = old_table->bins[i];
  1132. X    while (ptr != nil(st_table_entry)) {
  1133. X        new = alloc(st_table_entry);
  1134. X        if (new == nil(st_table_entry)) {
  1135. X        free((char *) new_table->bins);
  1136. X        free((char *) new_table);
  1137. X        return nil(st_table);
  1138. X        }
  1139. X        *new = *ptr;
  1140. X        new->next = new_table->bins[i];
  1141. X        new_table->bins[i] = new;
  1142. X        ptr = ptr->next;
  1143. X    }
  1144. X    }
  1145. X    return new_table;
  1146. X}
  1147. X
  1148. Xst_delete(table, key, value)
  1149. Xregister st_table *table;
  1150. Xregister char **key;
  1151. Xchar **value;
  1152. X{
  1153. X    int hash_val;
  1154. X    st_table_entry *tmp;
  1155. X    register st_table_entry *ptr;
  1156. X
  1157. X    hash_val = do_hash(*key, table);
  1158. X
  1159. X    ptr = table->bins[hash_val];
  1160. X
  1161. X    if (ptr == nil(st_table_entry)) {
  1162. X    *value = nil(char);
  1163. X    return 0;
  1164. X    }
  1165. X
  1166. X    if (EQUAL(table->compare, *key, ptr->key)) {
  1167. X    table->bins[hash_val] = ptr->next;
  1168. X    table->num_entries--;
  1169. X    if (value != nil(char *)) *value = ptr->record;
  1170. X    *key = ptr->key;
  1171. X    free((char *) ptr);
  1172. X    return 1;
  1173. X    }
  1174. X
  1175. X    for(; ptr->next != nil(st_table_entry); ptr = ptr->next) {
  1176. X    if (EQUAL(table->compare, ptr->next->key, *key)) {
  1177. X        tmp = ptr->next;
  1178. X        ptr->next = ptr->next->next;
  1179. X        if (value != nil(char *)) *value = tmp->record;
  1180. X        *key = tmp->key;
  1181. X        free((char *) tmp);
  1182. X        return 1;
  1183. X    }
  1184. X    }
  1185. X
  1186. X    return 0;
  1187. X}
  1188. X
  1189. Xst_foreach(table, func, arg)
  1190. Xst_table *table;
  1191. Xenum st_retval (*func)();
  1192. Xchar *arg;
  1193. X{
  1194. X    st_table_entry *ptr, *last, *tmp;
  1195. X    enum st_retval retval;
  1196. X    int i;
  1197. X
  1198. X    for(i = 0; i < table->num_bins; i++) {
  1199. X    last = nil(st_table_entry);
  1200. X    for(ptr = table->bins[i]; ptr != nil(st_table_entry);) {
  1201. X        retval = (*func)(ptr->key, ptr->record, arg);
  1202. X        switch (retval) {
  1203. X        case ST_CONTINUE:
  1204. X        last = ptr;
  1205. X        ptr = ptr->next;
  1206. X        break;
  1207. X        case ST_STOP:
  1208. X        return;
  1209. X        case ST_DELETE:
  1210. X        tmp = ptr;
  1211. X        if (last == nil(st_table_entry)) {
  1212. X            table->bins[i] = ptr->next;
  1213. X        } else {
  1214. X            last->next = ptr->next;
  1215. X        }
  1216. X        ptr = ptr->next;
  1217. X        free((char *) tmp);
  1218. X        }
  1219. X    }
  1220. X    }
  1221. X}
  1222. X
  1223. Xst_strhash(string, modulus)
  1224. Xregister char *string;
  1225. Xint modulus;
  1226. X{
  1227. X    register int val = 0;
  1228. X    register int c;
  1229. X    
  1230. X    while ((c = *string++) != '\0') {
  1231. X    val = val*997 + c;
  1232. X    }
  1233. X
  1234. X    return ((val < 0) ? -val : val)%modulus;
  1235. X}
  1236. END_OF_FILE
  1237. if test 8091 -ne `wc -c <'st.c'`; then
  1238.     echo shar: \"'st.c'\" unpacked with wrong size!
  1239. fi
  1240. # end of 'st.c'
  1241. fi
  1242. if test -f 'winmenu.c' -a "${1}" != "-c" ; then 
  1243.   echo shar: Will not clobber existing file \"'winmenu.c'\"
  1244. else
  1245. echo shar: Extracting \"'winmenu.c'\" \(7303 characters\)
  1246. sed "s/^X//" >'winmenu.c' <<'END_OF_FILE'
  1247. X/*
  1248. X *      (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
  1249. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  1250. X *      file for terms of the license.
  1251. X */
  1252. X
  1253. X#ident    "@(#)winmenu.c    1.1 olvwm version 1/3/92"
  1254. X
  1255. X/*
  1256. X * Based on
  1257. X#ident    "@(#)winmenu.c    26.14    91/09/14 SMI"
  1258. X *
  1259. X */
  1260. X
  1261. X#include <errno.h>
  1262. X#include <stdio.h>
  1263. X#include <X11/Xos.h>
  1264. X#include <X11/Xlib.h>
  1265. X#include <X11/Xutil.h>
  1266. X#include <X11/Xatom.h>
  1267. X#include <olgx/olgx.h>
  1268. X
  1269. X#include "i18n.h"
  1270. X#include "ollocale.h"
  1271. X#include "mem.h"
  1272. X#include "olwm.h"
  1273. X#include "win.h"
  1274. X#include "menu.h"
  1275. X#include "globals.h"
  1276. X
  1277. X/***************************************************************************
  1278. X* private data
  1279. X***************************************************************************/
  1280. X
  1281. X/* function vector for menu windows */
  1282. Xstatic ClassMenu classMenu;
  1283. X
  1284. X#define    MENU_EVENT_MASK        (PropertyChangeMask|SubstructureNotifyMask)
  1285. X#define    MENU_ATTR_EVENT_MASK    (ButtonPressMask|ExposureMask)
  1286. X
  1287. X#define MENU_SHADOW_OFFSET    (10);
  1288. X
  1289. X/***************************************************************************
  1290. X* private functions
  1291. X***************************************************************************/
  1292. X
  1293. X/* REMIND - none yet */
  1294. X
  1295. X/***************************************************************************
  1296. X*  private event functions
  1297. X***************************************************************************/
  1298. X
  1299. X/* 
  1300. X * eventButtonPress  - a button has gone down.
  1301. X */
  1302. Xstatic int
  1303. XeventButtonPress(dpy, event, winInfo)
  1304. X    Display        *dpy;
  1305. X    XEvent        *event;
  1306. X    WinMenu        *winInfo;
  1307. X{
  1308. X    /* REMIND - placeholder for future */
  1309. X}
  1310. X
  1311. X/* 
  1312. X * eventButtonRelease  - a button has gone up
  1313. X */
  1314. Xstatic int
  1315. XeventButtonRelease(dpy, event, winInfo)
  1316. X    Display        *dpy;
  1317. X    XEvent        *event;
  1318. X    WinMenu        *winInfo;
  1319. X{
  1320. X    /* REMIND - placeholder for future */
  1321. X}
  1322. X
  1323. X/* 
  1324. X * eventKeyPress  - a key has gone down
  1325. X */
  1326. Xstatic int
  1327. XeventKeyPress(dpy, event, winInfo)
  1328. X    Display        *dpy;
  1329. X    XEvent        *event;
  1330. X    WinMenu        *winInfo;
  1331. X{
  1332. X    /* REMIND - mouseless operation */
  1333. X}
  1334. X
  1335. X/* 
  1336. X * eventKeyRelease  - a key has gone up
  1337. X */
  1338. Xstatic int
  1339. XeventKeyRelease(dpy, event, winInfo)
  1340. X    Display        *dpy;
  1341. X    XEvent        *event;
  1342. X    WinMenu        *winInfo;
  1343. X{
  1344. X    /* REMIND - mouseless operation */
  1345. X}
  1346. X
  1347. X/* 
  1348. X * eventMotionNotify - mouse moved
  1349. X */
  1350. Xstatic int
  1351. XeventMotionNotify(dpy, event, winInfo)
  1352. X    Display        *dpy;
  1353. X    XEvent        *event;
  1354. X    WinMenu        *winInfo;
  1355. X{
  1356. X    /* REMIND - placeholder for future */
  1357. X}
  1358. X
  1359. X/*
  1360. X * destroyMenu -- destroy the menu window resources and free any allocated
  1361. X *    data.
  1362. X */
  1363. Xstatic int
  1364. XdestroyMenu(dpy, winInfo)
  1365. X    Display        *dpy;
  1366. X    WinMenu     *winInfo;
  1367. X{
  1368. X    XUndefineCursor(dpy, winInfo->core.self);
  1369. X    XDestroyWindow(dpy, winInfo->core.self);
  1370. X#ifdef SHADOW
  1371. X    XDestroyWindow(dpy, winInfo->menu.shadow);
  1372. X#endif /* SHADOW */
  1373. X    MemFree(winInfo);
  1374. X}
  1375. X
  1376. X
  1377. X/***************************************************************************
  1378. X* global functions
  1379. X***************************************************************************/
  1380. X
  1381. X/*
  1382. X * MakeMenu  -- create the WinMenu structure and windows but does not
  1383. X *        map them.
  1384. X */
  1385. XWinMenu *
  1386. XMakeMenu(dpy, winInfo)
  1387. X    Display        *dpy;
  1388. X    WinGeneric     *winInfo;
  1389. X{
  1390. X    WinMenu     *w;
  1391. X    Window         win;
  1392. X        unsigned long     valuemask;
  1393. X        XSetWindowAttributes attributes;
  1394. X    Client        *cli = winInfo->core.client;
  1395. X
  1396. X    /* create the associated structure */
  1397. X    w = MemNew(WinMenu);
  1398. X    w->class = &classMenu;
  1399. X    w->core.kind = WIN_MENU;
  1400. X    w->core.children = NULL;
  1401. X    w->core.client = cli;
  1402. X    w->core.x = 0;
  1403. X    w->core.y = 0;
  1404. X    w->core.width = 1;
  1405. X    w->core.height = 1;
  1406. X    /* REMIND - is dirtyconfig necessary??? */
  1407. X    w->core.dirtyconfig = CWX|CWY|CWWidth|CWHeight;
  1408. X    w->core.exposures = NULL;
  1409. X    w->core.helpstring = (char *)0;
  1410. X
  1411. X    /* Menu window. */
  1412. X    attributes.event_mask = MENU_ATTR_EVENT_MASK;
  1413. X    attributes.save_under = DoesSaveUnders(
  1414. X                    ScreenOfDisplay(dpy,cli->screen));
  1415. X    attributes.border_pixel = 0;
  1416. X    attributes.colormap = cli->scrInfo->colormap;
  1417. X    valuemask = CWEventMask | CWSaveUnder | CWBorderPixel | CWColormap;
  1418. X
  1419. X    win = XCreateWindow(dpy, WinRootID(winInfo),
  1420. X            w->core.x, w->core.y,
  1421. X            w->core.width, w->core.height,
  1422. X            0,
  1423. X            WinDepth(winInfo),
  1424. X            InputOutput,
  1425. X            WinVisual(winInfo),
  1426. X            valuemask,
  1427. X            &attributes);
  1428. X    w->core.self = win;
  1429. X
  1430. X    WIInstallInfo(w);
  1431. X
  1432. X#ifdef SHADOW
  1433. X    /* REMIND - there is no pixmapGray - what to use really??? */
  1434. X    attributes.background_pixmap = pixmapGray;
  1435. X    attributes.save_under = DoesSaveUnders(cli->screen);
  1436. X    w->shadow = XCreateWindow(dpy, WinRootID(winInfo),
  1437. X            0, 0, 1, 1,
  1438. X            0,
  1439. X            WinDepth(winInfo),
  1440. X            InputOutput,
  1441. X            WinVisual(winInfo),
  1442. X            CWBackPixmap |  CWSaveUnder,
  1443. X            &attributes);
  1444. X#endif /* SHADOW */
  1445. X
  1446. X    XDefineCursor( dpy, win, GRV.MenuPointer );
  1447. X
  1448. X    return w;
  1449. X}
  1450. X
  1451. X/*
  1452. X * MapMenuWindow - Configures (sizes) and maps the WinMenu windows
  1453. X */
  1454. Xvoid
  1455. XMapMenuWindow(dpy,winInfo,menuInfo)
  1456. X    Display        *dpy;
  1457. X    WinMenu        *winInfo;
  1458. X    MenuInfo    *menuInfo;
  1459. X{
  1460. X    XWindowChanges    changes;
  1461. X
  1462. X    /* position, size and map menu window */
  1463. X    winInfo->core.x = menuInfo->menuX;
  1464. X    winInfo->core.y = menuInfo->menuY;
  1465. X    winInfo->core.width = menuInfo->menuWidth;
  1466. X    winInfo->core.height = menuInfo->menuHeight;
  1467. X    changes.x = winInfo->core.x;
  1468. X    changes.y = winInfo->core.y;
  1469. X    changes.width = winInfo->core.width;
  1470. X    changes.height = winInfo->core.height;
  1471. X    ConfigureWindow(dpy,winInfo,
  1472. X        CWX|CWY|CWWidth|CWHeight,&changes);
  1473. X    MapRaised(winInfo);
  1474. X
  1475. X#ifdef SHADOW
  1476. X
  1477. X    /* map shadow below menu window */
  1478. X    changes.x = menuInfo.menuX + MENU_SHADOW_OFFSET;
  1479. X    changes.y = menuInfo.menuY + MENU_SHADOW_OFFSET;
  1480. X    changes.sibling = winInfo->core.self;
  1481. X    change.stack_mode = Below;
  1482. X    ConfigureWindow(dpy,winInfo,
  1483. X        CWX|CWY|CWWidth|CWHeight|CWStackMode|CWSibling,&changes);
  1484. X#endif /* SHADOW */
  1485. X
  1486. X    /* save the menuinfo */
  1487. X    winInfo->menuInfo = menuInfo;
  1488. X
  1489. X    DrawMenu(dpy,menuInfo);
  1490. X}
  1491. X
  1492. X/*
  1493. X * UnmapMenuWindow - take down WinMenu windows
  1494. X */
  1495. Xvoid
  1496. XUnmapMenuWindow(dpy,winInfo)
  1497. X    Display        *dpy;
  1498. X    WinMenu        *winInfo;
  1499. X{
  1500. X    UnmapWindow(winInfo);
  1501. X#ifdef SHADOW
  1502. X    XUnmapWindow(dpy,winInfo->shadow);
  1503. X#endif /* SHADOW */
  1504. X    winInfo->menuInfo = (MenuInfo *)NULL;
  1505. X}
  1506. X
  1507. X
  1508. Xint
  1509. XMenuEventExpose(dpy, event, winInfo)
  1510. X    Display *dpy;
  1511. X    XEvent *event;
  1512. X    WinGeneric *winInfo;
  1513. X{
  1514. X    MenuInfo *mInfo = NULL;
  1515. X
  1516. X    if (winInfo->core.kind == WIN_MENU)
  1517. X    mInfo = ((WinMenu *) winInfo)->menuInfo;
  1518. X    else
  1519. X    mInfo = ((WinPinMenu *) winInfo)->menuInfo;
  1520. X        
  1521. X    if (mInfo == NULL) /*not yet reparented*/
  1522. X    WinEventExpose(dpy, event, winInfo);
  1523. X    else {
  1524. X    SetMenuRedrawHints(dpy, event, mInfo);
  1525. X
  1526. X    if (event->xexpose.count == 0)
  1527. X        DrawMenuWithHints(dpy, mInfo);
  1528. X    }
  1529. X}
  1530. X
  1531. X/*
  1532. X * drawMenu -- draw the menu window
  1533. X */
  1534. Xint
  1535. XMenuEventDrawMenu(dpy, winInfo)
  1536. X    Display    *dpy;
  1537. X    WinGeneric     *winInfo;
  1538. X{
  1539. X    MenuInfo *mInfo = NULL;
  1540. X
  1541. X    if (winInfo->core.kind == WIN_MENU)
  1542. X    mInfo = ((WinMenu *) winInfo)->menuInfo;
  1543. X    else
  1544. X    mInfo = ((WinPinMenu *) winInfo)->menuInfo;
  1545. X
  1546. X    if (mInfo)
  1547. X    DrawMenu(dpy, mInfo);
  1548. X}
  1549. X
  1550. X
  1551. X/*
  1552. X * MenuInit - initialize WinMenu class functions
  1553. X */
  1554. X/*ARGSUSED*/
  1555. Xvoid
  1556. XMenuInit(dpy)
  1557. XDisplay *dpy;
  1558. X{
  1559. X    classMenu.core.kind = WIN_MENU;
  1560. X    classMenu.core.xevents[ButtonPress] = eventButtonPress;
  1561. X    classMenu.core.xevents[ButtonRelease] = eventButtonRelease;
  1562. X    classMenu.core.xevents[MotionNotify] = eventMotionNotify;
  1563. X    classMenu.core.xevents[KeyPress] = eventKeyPress;
  1564. X    classMenu.core.xevents[KeyRelease] = eventKeyRelease;
  1565. X    classMenu.core.xevents[Expose] = MenuEventExpose;
  1566. X    classMenu.core.drawfunc = MenuEventDrawMenu;
  1567. X    classMenu.core.destroyfunc = destroyMenu;
  1568. X    classMenu.core.heightfunc = NULL;
  1569. X    classMenu.core.widthfunc = NULL;
  1570. X}
  1571. END_OF_FILE
  1572. if test 7303 -ne `wc -c <'winmenu.c'`; then
  1573.     echo shar: \"'winmenu.c'\" unpacked with wrong size!
  1574. fi
  1575. # end of 'winmenu.c'
  1576. fi
  1577. if test -f 'winnofoc.c' -a "${1}" != "-c" ; then 
  1578.   echo shar: Will not clobber existing file \"'winnofoc.c'\"
  1579. else
  1580. echo shar: Extracting \"'winnofoc.c'\" \(7314 characters\)
  1581. sed "s/^X//" >'winnofoc.c' <<'END_OF_FILE'
  1582. X/*
  1583. X *      (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
  1584. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  1585. X *      file for terms of the license.
  1586. X */
  1587. X
  1588. X#ident    "@(#)winnofoc.c    1.1 olvwm version 1/3/92"
  1589. X
  1590. X/*
  1591. X * Based on
  1592. X#ident    "@(#)winnofoc.c    26.17    91/09/14 SMI"
  1593. X *
  1594. X */
  1595. X
  1596. X#include <errno.h>
  1597. X#include <stdio.h>
  1598. X#include <X11/Xos.h>
  1599. X#include <X11/Xlib.h>
  1600. X#include <X11/Xutil.h>
  1601. X#include <X11/Xatom.h>
  1602. X#include <olgx/olgx.h>
  1603. X
  1604. X#include "i18n.h"
  1605. X#include "ollocale.h"
  1606. X#include "mem.h"
  1607. X#include "olwm.h"
  1608. X#include "win.h"
  1609. X#include "globals.h"
  1610. X
  1611. Xextern unsigned int FindModifierMask();
  1612. Xextern Atom AtomProtocols;
  1613. Xextern Atom AtomTakeFocus;
  1614. Xextern void ClientSetCurrent();
  1615. X
  1616. X/***************************************************************************
  1617. X* global data
  1618. X***************************************************************************/
  1619. X
  1620. XWindow NoFocusWin = NULL;
  1621. XWinNoFocus *NoFocusWinInfo;
  1622. X
  1623. X/***************************************************************************
  1624. X* private data
  1625. X***************************************************************************/
  1626. X
  1627. Xstatic     ClassNoFocus     classNoFocus;
  1628. X
  1629. X/***************************************************************************
  1630. X* private functions
  1631. X***************************************************************************/
  1632. X
  1633. X/*
  1634. X * DestroyNoFocus -- destroy the no-focus window and free any allocated
  1635. X *    data.
  1636. X */
  1637. Xstatic int
  1638. XdestroyNoFocus(dpy, winInfo)
  1639. XDisplay    *dpy;
  1640. XWinGeneric *winInfo;
  1641. X{
  1642. X    /* free our data and throw away window */
  1643. X    DestroyWindow(winInfo);
  1644. X    MemFree(winInfo);
  1645. X}
  1646. X
  1647. X
  1648. X/*
  1649. X * eventClientMessage - handle WM_TAKE_FOCUS messages.  This is a vestige of a 
  1650. X * previous focus-handling scheme.  However, it remains, in case it becomes 
  1651. X * useful at some time for the no-focus window to respond to WM_TAKE_FOCUS 
  1652. X * messages.
  1653. X */
  1654. Xstatic int
  1655. XeventClientMessage(dpy, event, winInfo)
  1656. X    Display *dpy;
  1657. X    XEvent *event;
  1658. X    WinNoFocus *winInfo;
  1659. X{
  1660. X    if (event->xclient.message_type == AtomProtocols &&
  1661. X    event->xclient.data.l[0] == AtomTakeFocus &&
  1662. X    event->xclient.format == 32)
  1663. X    {
  1664. X    NoFocusTakeFocus(dpy, event->xclient.data.l[1],
  1665. X             winInfo->core.client->scrInfo);
  1666. X    }
  1667. X}
  1668. X
  1669. X
  1670. X/* 
  1671. X * eventSelectionNotify - someone else has asked for the selection value
  1672. X */
  1673. Xstatic int
  1674. XeventSelectionNotify(dpy, pEvent, winInfo)
  1675. X    Display        *dpy;
  1676. X    XEvent        *pEvent;
  1677. X    WinNoFocus    *winInfo;
  1678. X{
  1679. X    /*
  1680. X     * We get this event from the owner of the selection if we had made a
  1681. X     * XConvertSelection call.  Presently, olwm never makes any
  1682. X     * XConvertSelection requests, so we don't have to worry about a
  1683. X     * SelectionNotify event.
  1684. X     */
  1685. X}
  1686. X
  1687. X
  1688. X/* 
  1689. X * eventSelectionRequest - someone else has asked for the selection value
  1690. X */
  1691. Xstatic int
  1692. XeventSelectionRequest(dpy, pEvent, winInfo)
  1693. X    Display        *dpy;
  1694. X    XEvent        *pEvent;
  1695. X    WinNoFocus    *winInfo;
  1696. X{
  1697. X    SelectionResponse((XSelectionRequestEvent *)pEvent);
  1698. X}
  1699. X
  1700. X
  1701. X/* 
  1702. X * eventSelectionClear - someone else has asked to be the selection owner
  1703. X */
  1704. Xstatic int
  1705. XeventSelectionClear(dpy, pEvent, winInfo)
  1706. X    Display        *dpy;
  1707. X    XEvent        *pEvent;
  1708. X    WinNoFocus    *winInfo;
  1709. X{
  1710. X    /*
  1711. X     * Someone else has asked to be the selection owner.
  1712. X     * Clear our list of selected windows.
  1713. X     */
  1714. X    ClearSelections(dpy);
  1715. X}
  1716. X
  1717. X
  1718. X/***************************************************************************
  1719. X* global functions
  1720. X***************************************************************************/
  1721. X
  1722. X/*
  1723. X * MakeNoFocus  -- create the no-focus windows to a window. Return a 
  1724. X * WinGeneric structure.
  1725. X */
  1726. XWinGeneric *
  1727. XMakeNoFocus(dpy, par)
  1728. XDisplay    *dpy;
  1729. XWinGeneric *par;
  1730. X{
  1731. X    XSetWindowAttributes attributes;
  1732. X    WinNoFocus *w;
  1733. X
  1734. X    /* create the window */
  1735. X    attributes.event_mask = KeyPressMask;
  1736. X    attributes.override_redirect = True;
  1737. X    NoFocusWin = XCreateWindow(dpy, par->core.self,
  1738. X             -10, -10,
  1739. X             10, 10    ,
  1740. X             0,
  1741. X             0,
  1742. X             InputOnly,
  1743. X             CopyFromParent,
  1744. X             CWEventMask | CWOverrideRedirect,
  1745. X             &attributes);
  1746. X    XMapWindow(dpy, NoFocusWin);
  1747. X
  1748. X    /* create the associated structure */
  1749. X    w = MemNew(WinNoFocus);
  1750. X    w->core.self = NoFocusWin;
  1751. X    w->core.kind = WIN_NOFOCUS;
  1752. X    w->class = &classNoFocus;
  1753. X    w->core.parent = par;
  1754. X    w->core.children = NULL;
  1755. X    w->core.client = par->core.client;
  1756. X    w->core.x = -10;
  1757. X    w->core.y = -10;
  1758. X    w->core.width = 10;
  1759. X    w->core.height = 10;
  1760. X    w->core.dirtyconfig = False;
  1761. X    w->core.exposures = NULL;
  1762. X    w->core.helpstring = (char *)NULL;     /* no help */
  1763. X
  1764. X    /* register the window */
  1765. X    WIInstallInfo(w);
  1766. X
  1767. X    /* set the focus to the NoFocusWin */
  1768. X    NoFocusWinInfo = w;
  1769. X
  1770. X    return w;
  1771. X}
  1772. X
  1773. X/*
  1774. X * Handle a key press in the no focus window.  If its a standard Virtual
  1775. X * Desktop function -- up, down, etc. -- then execute it, otherwise beep
  1776. X */
  1777. Xstatic int
  1778. XNoFocusKey(dpy, event, winInfo)
  1779. XDisplay    *dpy;
  1780. XXEvent    *event;
  1781. XWinGeneric *winInfo;
  1782. X
  1783. X{
  1784. X    if (!GRV.ArrowInRoot || !KeyMoveVDM(dpy, event))
  1785. X    NoFocusEventBeep(dpy, event, winInfo);
  1786. X}
  1787. X
  1788. Xvoid
  1789. XNoFocusInit(dpy)
  1790. XDisplay *dpy;
  1791. X{
  1792. X    classNoFocus.core.kind = WIN_NOFOCUS;
  1793. X    classNoFocus.core.xevents[ButtonPress] = NoFocusEventBeep;
  1794. X    classNoFocus.core.xevents[ButtonRelease] = NoFocusEventBeep;
  1795. X    classNoFocus.core.xevents[KeyPress] = NoFocusKey;  /*NoFocusEventBeep;
  1796. X    classNoFocus.core.xevents[KeyRelease] = NoFocusEventBeep; */
  1797. X    classNoFocus.core.xevents[ClientMessage] = eventClientMessage;
  1798. X    classNoFocus.core.xevents[SelectionNotify] = eventSelectionNotify;
  1799. X    classNoFocus.core.xevents[SelectionRequest] = eventSelectionRequest;
  1800. X    classNoFocus.core.xevents[SelectionClear] = eventSelectionClear;
  1801. X    classNoFocus.core.focusfunc = NULL;
  1802. X    classNoFocus.core.drawfunc = NULL;
  1803. X    classNoFocus.core.destroyfunc = destroyNoFocus;
  1804. X    classNoFocus.core.selectfunc = NULL;
  1805. X    classNoFocus.core.newconfigfunc = NULL;
  1806. X    classNoFocus.core.newposfunc = NULL;
  1807. X    classNoFocus.core.setconfigfunc = NULL;
  1808. X    classNoFocus.core.createcallback = NULL;
  1809. X    classNoFocus.core.heightfunc = NULL;
  1810. X    classNoFocus.core.widthfunc = NULL;
  1811. X}
  1812. X
  1813. X
  1814. X/*
  1815. X * Set the focus to the NoFocus window.  If colormap installation is tracking 
  1816. X * the focus, install and lock the default colormap for this screen.
  1817. X */
  1818. Xvoid
  1819. XNoFocusTakeFocus(dpy,evtime,scrInfo)
  1820. XDisplay *dpy;
  1821. XTime evtime;
  1822. XScreenInfo *scrInfo;
  1823. X{
  1824. X    XSetInputFocus(dpy, NoFocusWin, RevertToParent, evtime);
  1825. X    ClientSetCurrent(NoFocusWinInfo->core.client);
  1826. X    ClientDefaultWindowState(dpy);
  1827. X    if (scrInfo != NULL && GRV.ColorTracksInputFocus)
  1828. X        InstallDefaultColormap(dpy, scrInfo->rootwin, True);
  1829. X}
  1830. X
  1831. X/*
  1832. X * NoFocusEventBeep -- beep on keyboard/mouse events for the no-focus window
  1833. X *    Also used by busy windows
  1834. X */
  1835. Xint
  1836. XNoFocusEventBeep(dpy, event, winInfo)
  1837. XDisplay    *dpy;
  1838. XXEvent    *event;
  1839. XWinGeneric *winInfo;
  1840. X{
  1841. X        XEvent dummy;
  1842. X
  1843. X    if (FindModifierMask(event->xkey.keycode) != 0)
  1844. X        return;
  1845. X
  1846. X        XSync(dpy,0);
  1847. X        /*
  1848. X         * Discard pending keyboard and mouse events on this
  1849. X         * window, and then beep once.
  1850. X         */
  1851. X        while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
  1852. X                                      KeyPress,&dummy))
  1853. X        /*EMPTY*/
  1854. X            ;
  1855. X        while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
  1856. X                                      KeyRelease,&dummy))
  1857. X        /*EMPTY*/
  1858. X            ;
  1859. X        while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
  1860. X                                      ButtonPress,&dummy))
  1861. X        /*EMPTY*/
  1862. X            ;
  1863. X        while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
  1864. X                                      ButtonRelease,&dummy))
  1865. X        /*EMPTY*/
  1866. X            ;
  1867. X    KeyBeep(dpy,event);
  1868. X}
  1869. END_OF_FILE
  1870. if test 7314 -ne `wc -c <'winnofoc.c'`; then
  1871.     echo shar: \"'winnofoc.c'\" unpacked with wrong size!
  1872. fi
  1873. # end of 'winnofoc.c'
  1874. fi
  1875. if test -f 'winresize.c' -a "${1}" != "-c" ; then 
  1876.   echo shar: Will not clobber existing file \"'winresize.c'\"
  1877. else
  1878. echo shar: Extracting \"'winresize.c'\" \(8191 characters\)
  1879. sed "s/^X//" >'winresize.c' <<'END_OF_FILE'
  1880. X/*
  1881. X *      (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
  1882. X *      pending in the U.S. and foreign countries. See LEGAL_NOTICE
  1883. X *      file for terms of the license.
  1884. X */
  1885. X
  1886. X#ident    "@(#)winresize.c    1.1 olvwm version 1/3/92"
  1887. X
  1888. X/*
  1889. X * Based on
  1890. X#ident    "@(#)winresize.c    26.22    91/09/14 SMI"
  1891. X *
  1892. X */
  1893. X
  1894. X#include <errno.h>
  1895. X#include <stdio.h>
  1896. X#include <X11/Xos.h>
  1897. X#include <X11/Xlib.h>
  1898. X#include <X11/Xutil.h>
  1899. X#include <X11/Xatom.h>
  1900. X#include <X11/keysym.h>
  1901. X#include <olgx/olgx.h>
  1902. X
  1903. X#include "ollocale.h"
  1904. X#include "i18n.h"
  1905. X#include "mem.h"
  1906. X#include "olwm.h"
  1907. X#include "win.h"
  1908. X#include "globals.h"
  1909. X#include "events.h"
  1910. X
  1911. X/***************************************************************************
  1912. X* global data
  1913. X***************************************************************************/
  1914. X
  1915. Xextern int Resize_width, Resize_height;
  1916. Xextern void FrameAllowEvents();
  1917. X
  1918. X/***************************************************************************
  1919. X* private data
  1920. X***************************************************************************/
  1921. X
  1922. Xstatic int whicholgx[] = {OLGX_UPPER_LEFT, OLGX_UPPER_RIGHT, 
  1923. X    OLGX_LOWER_LEFT, OLGX_LOWER_RIGHT};
  1924. Xstatic int whichgrav[] = {NorthWestGravity, NorthEastGravity, 
  1925. X    SouthWestGravity, SouthEastGravity};
  1926. X
  1927. Xstatic ClassResize classResize;
  1928. X
  1929. X/***************************************************************************
  1930. X* private functions
  1931. X***************************************************************************/
  1932. X
  1933. X/*
  1934. X * resizeCallback - restore the resize corner to its normal state
  1935. X */
  1936. Xstatic void
  1937. XresizeCallback(dpy, winInfo)
  1938. X    Display *dpy;
  1939. X    WinResize *winInfo;
  1940. X{
  1941. X    winInfo->depressed = False;
  1942. X    (WinFunc(winInfo,core.drawfunc))(dpy,winInfo);
  1943. X}
  1944. X
  1945. X
  1946. X/* 
  1947. X * eventButtonPress - handle button press events on the resize window 
  1948. X */
  1949. Xstatic int
  1950. XeventButtonPress(dpy, event, winInfo)
  1951. XDisplay    *dpy;
  1952. XXEvent    *event;
  1953. XWinResize    *winInfo;
  1954. X{
  1955. X    unsigned int ignoremask =
  1956. X        ModMaskMap[MOD_CONSTRAIN] | ModMaskMap[MOD_INVERT];
  1957. X
  1958. X        if (ResolveMouseBinding(dpy, event, ignoremask) != ACTION_SELECT) {
  1959. X        FrameAllowEvents(winInfo->core.client, event->xbutton.time);
  1960. X        return;
  1961. X    }
  1962. X
  1963. X    /* draw depressed corner */
  1964. X    winInfo->depressed = True;
  1965. X        (WinFunc(winInfo,core.drawfunc))(dpy,winInfo);
  1966. X
  1967. X    /* resize function will eat button release */
  1968. X    ClientResize(winInfo->core.client,event,winInfo->which,
  1969. X             resizeCallback,winInfo);
  1970. X}
  1971. X
  1972. X
  1973. X/*
  1974. X * drawResize -- draw the resize window
  1975. X */
  1976. X/*ARGSUSED*/
  1977. Xstatic int
  1978. XdrawResize(dpy, winInfo)
  1979. XDisplay    *dpy;
  1980. XWinResize *winInfo;
  1981. X{
  1982. X    WhichResize     which = winInfo->which;
  1983. X    GC        drawForegroundGC = WinGC(winInfo,FOREGROUND_GC);
  1984. X    GC        drawWindowGC = WinGC(winInfo,WINDOW_GC);
  1985. X    GC        drawBusyGC = WinGC(winInfo,BUSY_GC);
  1986. X    Graphics_info    *gis = WinGI(winInfo,NORMAL_GINFO);
  1987. X
  1988. X    int        focusLines;    /* two lines or solid bar */
  1989. X
  1990. X    if (winInfo->core.client->isFocus) {
  1991. X        drawWindowGC = WinGC(winInfo, INPUTFOCUS_GC);
  1992. X        gis = WinGI(winInfo, INPUTFOCUS_GINFO);
  1993. X    }
  1994. X
  1995. X    focusLines = (GRV.FocusFollowsMouse ? 1 : 0) ^
  1996. X             (GRV.InvertFocusHighlighting ? 1 : 0);
  1997. X
  1998. X    if ((which == upright) || (which == upleft))
  1999. X    {
  2000. X        if (winInfo->core.client->isBusy) {
  2001. X        XFillRectangle(dpy,winInfo->core.self,drawWindowGC,
  2002. X            (which==upleft)?(ResizeArm_Width(gis)):(0),
  2003. X            ResizeArm_Height(gis), 
  2004. X            winInfo->core.width-ResizeArm_Width(gis),
  2005. X            winInfo->core.height-ResizeArm_Height(gis));
  2006. X        XFillRectangle(dpy,winInfo->core.self,drawBusyGC,
  2007. X            (which==upleft)?(ResizeArm_Width(gis)):(0),
  2008. X            ResizeArm_Height(gis), 
  2009. X            winInfo->core.width-ResizeArm_Width(gis),
  2010. X            winInfo->core.height-ResizeArm_Height(gis));
  2011. X        } else if ((winInfo->core.client->isFocus) && !focusLines) {
  2012. X        if (Win3D(winInfo)) {
  2013. X            olgx_draw_box(gis, winInfo->core.self,
  2014. X                (which==upleft)?(ResizeArm_Width(gis)):(-2),
  2015. X                ResizeArm_Height(gis), 
  2016. X                winInfo->core.width-ResizeArm_Width(gis)+2,
  2017. X                winInfo->core.height-ResizeArm_Height(gis)+2,
  2018. X            OLGX_INVOKED, True);
  2019. X        } else {
  2020. X            XFillRectangle(dpy,winInfo->core.self,
  2021. X            WinGC(winInfo,INPUTFOCUS_GC),
  2022. X                (which==upleft)?(ResizeArm_Width(gis)):(0),
  2023. X                ResizeArm_Height(gis), 
  2024. X                winInfo->core.width-ResizeArm_Width(gis),
  2025. X                winInfo->core.height-ResizeArm_Height(gis));
  2026. X        }
  2027. X        } else {
  2028. X        XFillRectangle(dpy,winInfo->core.self,drawWindowGC,
  2029. X            (which==upleft)?(ResizeArm_Width(gis)):(0),
  2030. X            ResizeArm_Height(gis), 
  2031. X            winInfo->core.width-ResizeArm_Width(gis),
  2032. X            winInfo->core.height-ResizeArm_Height(gis));
  2033. X        }
  2034. X    } else {    /* lowleft or lowright */
  2035. X        XFillRectangle(dpy, winInfo->core.self, drawWindowGC,
  2036. X            (which==lowleft) ? (ResizeArm_Width(gis)) : 0, 0,
  2037. X            winInfo->core.width-ResizeArm_Width(gis),
  2038. X            winInfo->core.height-ResizeArm_Height(gis));
  2039. X    }
  2040. X
  2041. X    if (!Win3D(winInfo) || !GRV.F3dResize)
  2042. X        gis = WinGI(winInfo, TEXT_GINFO);
  2043. X
  2044. X    olgx_draw_resize_corner(gis, winInfo->core.self, 0, 0,
  2045. X        whicholgx[winInfo->which],
  2046. X        (winInfo->depressed)?(OLGX_INVOKED):(OLGX_NORMAL));
  2047. X}
  2048. X
  2049. X
  2050. X/*
  2051. X * DestroyResize -- destroy the resize window resources and free any allocated
  2052. X *    data.
  2053. X */
  2054. Xstatic int
  2055. XdestroyResize(dpy, winInfo)
  2056. XDisplay    *dpy;
  2057. XWinGeneric *winInfo;
  2058. X{
  2059. X    /* free our data and throw away window */
  2060. X    XUndefineCursor(dpy, winInfo->core.self);
  2061. X    DestroyWindow(winInfo);
  2062. X    MemFree(winInfo);
  2063. X}
  2064. X
  2065. X/* 
  2066. X * focusselectResize - the focus or selection state has changed
  2067. X */
  2068. Xstatic int
  2069. XfocusResize(dpy, winInfo, selected)
  2070. XDisplay *dpy;
  2071. XWinResize *winInfo;
  2072. XBool selected;
  2073. X{
  2074. X    (WinFunc(winInfo,core.drawfunc))(dpy, winInfo);
  2075. X}
  2076. X
  2077. X/*
  2078. X * widthfuncResize - recomputes the width of the resize window
  2079. X */
  2080. Xstatic int 
  2081. XwidthfuncResize(win, pxcre)
  2082. XWinResize *win;
  2083. XXConfigureRequestEvent *pxcre;
  2084. X{
  2085. X    return Resize_width;
  2086. X}
  2087. X
  2088. X/*
  2089. X * heightfuncResize - recomputes the width of the resize window
  2090. X */
  2091. Xstatic int 
  2092. XheightfuncResize(win, pxcre)
  2093. XWinResize *win;
  2094. XXConfigureRequestEvent *pxcre;
  2095. X{
  2096. X    return Resize_height;
  2097. X}
  2098. X
  2099. X/***************************************************************************
  2100. X* global functions
  2101. X***************************************************************************/
  2102. X
  2103. X/*
  2104. X * MakeResize  -- create the resize window. Return a WinGeneric structure.
  2105. X */
  2106. XWinResize *
  2107. XMakeResize(dpy, par, which, x, y)
  2108. XDisplay    *dpy;
  2109. XWinGeneric *par;
  2110. XWhichResize which;
  2111. Xint x,y;
  2112. X{
  2113. X    WinResize *w;
  2114. X    Window win;
  2115. X        unsigned long valuemask;
  2116. X        XSetWindowAttributes attributes;
  2117. X
  2118. X        attributes.event_mask =
  2119. X        ButtonPressMask | ButtonMotionMask | ButtonReleaseMask
  2120. X        | ExposureMask | OwnerGrabButtonMask;
  2121. X        attributes.win_gravity = whichgrav[which];
  2122. X    attributes.cursor = GRV.ResizePointer;
  2123. X        valuemask = CWEventMask | CWWinGravity | CWCursor;
  2124. X
  2125. X        win = XCreateWindow(dpy, par->core.self,
  2126. X                         x, y,
  2127. X                         Resize_width, Resize_height,
  2128. X                         0,
  2129. X                         CopyFromParent,
  2130. X                         CopyFromParent,
  2131. X                         CopyFromParent,
  2132. X                         valuemask,
  2133. X                         &attributes);
  2134. X
  2135. X    /* create the associated structure */
  2136. X    w = MemNew(WinResize);
  2137. X    w->core.self = win;
  2138. X    w->class = &classResize;
  2139. X    w->core.kind = WIN_RESIZE;
  2140. X    WinAddChild(par,w);
  2141. X    w->core.children = NULL;
  2142. X    w->core.client = par->core.client;
  2143. X    w->core.x = x;    
  2144. X    w->core.y = y;
  2145. X    w->core.width = Resize_width;
  2146. X    w->core.height = Resize_height;
  2147. X    w->core.dirtyconfig = CWX | CWY | CWWidth | CWHeight;
  2148. X    w->core.exposures = NULL;
  2149. X    w->which = which;
  2150. X    w->core.helpstring = "olwm:ResizeCorner";
  2151. X
  2152. X    /* register the window */
  2153. X    WIInstallInfo(w);
  2154. X
  2155. X        MapRaised(w);
  2156. X
  2157. X    return w;
  2158. X}
  2159. X
  2160. X
  2161. X/* ResizeInit -- initialise values for the resize class 
  2162. X */
  2163. Xvoid
  2164. XResizeInit(dpy)
  2165. XDisplay *dpy;
  2166. X{
  2167. X    classResize.core.kind = WIN_RESIZE;
  2168. X    classResize.core.xevents[Expose] = WinEventExpose;
  2169. X    classResize.core.xevents[ButtonPress] = eventButtonPress;
  2170. X    classResize.core.focusfunc= focusResize;
  2171. X    classResize.core.drawfunc= drawResize;
  2172. X    classResize.core.destroyfunc = destroyResize;
  2173. X    classResize.core.selectfunc = NULL;
  2174. X    classResize.core.newconfigfunc = WinNewConfigFunc;
  2175. X    classResize.core.newposfunc = WinNewPosFunc;
  2176. X    classResize.core.setconfigfunc = WinSetConfigFunc;
  2177. X    classResize.core.createcallback = NULL;
  2178. X    classResize.core.heightfunc = heightfuncResize;
  2179. X    classResize.core.widthfunc = widthfuncResize;
  2180. X}
  2181. END_OF_FILE
  2182. if test 8191 -ne `wc -c <'winresize.c'`; then
  2183.     echo shar: \"'winresize.c'\" unpacked with wrong size!
  2184. fi
  2185. # end of 'winresize.c'
  2186. fi
  2187. echo shar: End of archive 19 \(of 21\).
  2188. cp /dev/null ark19isdone
  2189. MISSING=""
  2190. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  2191.     if test ! -f ark${I}isdone ; then
  2192.     MISSING="${MISSING} ${I}"
  2193.     fi
  2194. done
  2195. if test "${MISSING}" = "" ; then
  2196.     echo You have unpacked all 21 archives.
  2197.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2198. else
  2199.     echo You still need to unpack the following archives:
  2200.     echo "        " ${MISSING}
  2201. fi
  2202. ##  End of shell archive.
  2203. exit 0
  2204. --
  2205. Molecular Simulations, Inc.             mail: dcmartin@postgres.berkeley.edu
  2206. 796 N. Pastoria Avenue                  uucp: uwvax!ucbvax!dcmartin
  2207. Sunnyvale, California 94086             at&t: 408/522-9236
  2208.